package bomberman;

public class Player{
	private int posx;
	private int posy;
	static boolean debug = false;
	
	
	
	public int getPosx() {
		return posx;
	}
	
	public int getPosy() {
		return posy;
	}
	
	protected void setPosx(int x) {
		posx = x;
		log(x);
	}
	
	protected void setPosy(int y) {
		posy = y;
	}
	
	public void moveUp() {
		//System.out.println("moveUp "+getPosx() + "X "+ getPosy()+"Y");
		if(Bomberman.getLevel().freieStelle(getPosx(), getPosy()-1)) {
			setPosy(getPosy()-1);
			log("Stelle frei.");
		}
	}
	
	public void moveDown() {
		//System.out.println("moveDown "+getPosx() + "X "+ getPosy()+"Y");
		if(Bomberman.getLevel().freieStelle(getPosx(), getPosy()+1)) {
			setPosy(getPosy()+1);
			log("Stelle frei.");
		}
	}
	
	public void moveLeft() {
		//System.out.println("moveDown "+getPosx() + "X "+ getPosy()+"Y");
		if(Bomberman.getLevel().freieStelle(getPosx()-1, getPosy())) {
			setPosx(getPosx()-1);
			log("Stelle frei.");
		}
	}
	
	
	public void moveRight() {
		//System.out.println("moveDown "+getPosx() + "X "+ getPosy()+"Y");
		if(Bomberman.getLevel().freieStelle(getPosx()+1, getPosy())) {
			setPosx(getPosx()+1);
			log("Stelle frei.");
		}
	}
	
	public static void log(Object str) {
		if(debug) {
			System.out.println("LOG: "+str);
		}
	}
}
